export default {
	// 开启命名空间
	namespaced:true,
	// 数据节点
	state: () => ({
		address:JSON.parse(uni.getStorageSync('address') || '{}')
	}),
	// 方法
	mutations:{
		updateAddress(state,address){
			// 更新收货地址
			state.address = address
			// 调用 m_user 模块下的 saveAddressToStorage 方法 将address对象持久存储到本地    => 传给后端
			this.commit('m_user/saveAddressToStorage')
		},
		// 将地址存储到本地存储中
		saveAddressToStorage(state){
			uni.setStorageSync('address',JSON.stringify(state.address))
		}
	},
	getters:{
		// 数据包装    收货地址的拼接
		addstr(state){
			if(!state.address.provinceName) return ''
			return state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
		}
	}
}